package com.mlnadvertising.kuv;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class DetailsActivity extends Activity {

    int id;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.i("Details", "onCreate");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.details);
        Bundle bundle = getIntent().getExtras();

        if (bundle.getString("data") != null && bundle.getString("id") != null) {
            Log.i("DetailsActivity",
                    "bundle.getString(data): " + bundle.getString("data"));
            Log.i("DetailsActivity",
                    "bundle.getString(id): " + bundle.getString("id"));
            id = Integer.parseInt(bundle.getString("id"));
            TextView textView = (TextView) findViewById(R.id.details);
            textView.setText(bundle.getString("data"));
        }
        
/*        MobileAppTracker mobileAppTracker = MobileAppTrackerUtil.getMobileAppTracker(getApplicationContext());
        mobileAppTracker.trackAction("read_message");*/
    }

    @Override
    protected void onResume() {
        Log.i("Details", "onResume");
        super.onResume();

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.action_delete:
            // AlertUtil.showAlertMessage(getApplicationContext(), id);
            EkDatabaseHelper.getCategoryHelper(getApplicationContext())
                    .deleteKuv(id);
            Intent intent = new Intent(getApplicationContext(),
                    MainActivity.class);
            startActivity(intent);
            break;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onBackPressed() {
        Log.i("DetailsActivity", "onBackPressed");
        // super.onBackPressed();
        Intent intent = new Intent(getApplicationContext(), MainActivity.class);
        startActivity(intent);

    }

}
